package com.platform.enums;

import com.platform.comm.enums.IDictEntry;
import com.platform.comm.enums.IEnumItem;

/**
 * 资源共享属性
 *
 * @author zhangqian
 */
public enum DirShareKind implements IDictEntry, IEnumItem {
    /**
     * 依法公开
     */
    PUBLIC("PUBLIC", "依法公开"),

    /**
     * 政务共享查询
     */
    SHARE("SHARE", "政务共享查询"),

    /**
     * 授权查询
     */
    AUTH("AUTH", "授权查询");


    public final String code;
    public final String title;

    DirShareKind(String code, String title) {
        this.code = code;
        this.title = title;
    }

    public static DirShareKind parse(String code) {
        for (DirShareKind item : values()) {
            if (item.is(code)) {
                return item;
            }
        }
        return null;
    }

    public static DirShareKind parseText(String text) {
        for (DirShareKind item : values()) {
            if (item.isText(text)) {
                return item;
            }
        }
        return null;
    }

    private boolean isText(String text) {
        return this.title.equals(text);
    }

    @Override
    public boolean is(String code) {
        return this.code.equals(code);
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return title;
    }

    @Override
    public Object getData() {
        return this;
    }

}
